﻿
namespace BusinessApplication.Web.Services
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Data;
    using System.Linq;
    using System.ServiceModel.DomainServices.EntityFramework;
    using System.ServiceModel.DomainServices.Hosting;
    using System.ServiceModel.DomainServices.Server;
    using BusinessApplication.Web.Model;


    // Implements application logic using the DatabaseEntities context.
    // TODO: Add your application logic to these methods or in additional methods.
    // TODO: Wire up authentication (Windows/ASP.NET Forms) and uncomment the following to disable anonymous access
    // Also consider adding roles to restrict access as appropriate.
    // [RequiresAuthentication]
    [EnableClientAccess()]
    public class LocationsService : LinqToEntitiesDomainService<DatabaseEntities>
    {

        // TODO:
        // Consider constraining the results of your query method.  If you need additional input you can
        // add parameters to this method or create additional query methods with different names.
        // To support paging you will need to add ordering to the 'tbl_locations' query.
        public IQueryable<tbl_locations> GetTbl_locations()
        {


            return this.ObjectContext.tbl_locations;
        }

        public void InsertTbl_locations(tbl_locations tbl_locations)
        {
            if ((tbl_locations.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(tbl_locations, EntityState.Added);
            }
            else
            {
                this.ObjectContext.tbl_locations.AddObject(tbl_locations);
            }
        }

        public void UpdateTbl_locations(tbl_locations currenttbl_locations)
        {
            this.ObjectContext.tbl_locations.AttachAsModified(currenttbl_locations, this.ChangeSet.GetOriginal(currenttbl_locations));
        }

        public void DeleteTbl_locations(tbl_locations tbl_locations)
        {
            if ((tbl_locations.EntityState == EntityState.Detached))
            {
                this.ObjectContext.tbl_locations.Attach(tbl_locations);
            }
            this.ObjectContext.tbl_locations.DeleteObject(tbl_locations);
        }
    }
}


